package com.siblings.loan.ui.user.impl

import com.siblings.loan.analysis.util.GoogleInstallUtil
import com.siblings.loan.http.ApiService
import com.siblings.loan.http.ApiService.addCommonParams
import com.siblings.loan.http.HttpHelper
import com.siblings.loan.http.IHttpCallback
import org.json.JSONObject

/**
 * Siblings
 * @Author wwdeng
 * @CreateTime: 2024/6/14 16:26
 * @Annotation：用户登录 Model 实现
 */
class SibLoginModelImpl {

    /**
     * 发送验证码
     */
    fun sendSibSmsCodeAction(mobile: String, callBack: IHttpCallback) {
        val httpUrl = ApiService.getHttpUrl(ApiService.API_URL.SIB_API_SMS_URL)
        val params = JSONObject().addCommonParams().apply {
            put("path",ApiService.API_PATH.SIB_API_SEND_SMS_PATH)
            put("mobile",mobile)
        }
        HttpHelper.postSibAction(httpUrl,params,callBack)
    }

    /**
     * 登录
     */
    fun loginSibAction(mobile: String,code: String,directLoginFlag: String,callBack: IHttpCallback){
        val httpUrl = ApiService.getHttpUrl(ApiService.API_URL.SIB_API_LOGIN_URL)
        val params = JSONObject().addCommonParams().apply {
            put("path",ApiService.API_PATH.SIB_API_LOGIN_PATH)
            put("mobile",mobile)//手机号
            put("code",code)//验证码
            put("channelCode", GoogleInstallUtil.getInstallReferrer())//渠道号
            put("subChannelCode", GoogleInstallUtil.getInstallReferrer())//子渠道号
            put("directLoginFlag",directLoginFlag)//是否直接登录
        }
        HttpHelper.postSibAction(httpUrl,params,callBack)
    }
}